﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Collections;
namespace WindowsGame4
{
    public class Damageable : GameObject
    {
        public float curHealth, maxHealth;
        public float regenRate;
        public Damageable()
            : base()
        {
            curHealth = maxHealth = 100;
            regenRate = 0;
        }
        public virtual void TakeDamage(float damage)
        {
            UpdateHealth(-damage);
            color = new Vector4(1, curHealth / maxHealth, curHealth / maxHealth, 1);
        }
        public void UpdateHealth(float amount)
        {
            curHealth += amount;
            curHealth = MathHelper.Clamp(curHealth, 0, maxHealth);
        }
        public override void Update(float time)
        {
            UpdateHealth(regenRate * time);
            if (curHealth == 0)
                bDead = true;
            base.Update(time);
        }
    }
}
